home *** CD-ROM | disk | FTP | other *** search
- /* FILE: PStrFind.c
- Finds first occurance of p in t. */
- #include "PStrLib.h"
-
- PStrFind(p, t, pos)
- unsigned char *p, *t; /* Pascal strings */
- register int pos; /* char position in t to start search */
- { /* range of pos: 1 to 255 */
- register unsigned char *tp = t + pos, *pp = p, *ppe = p + *p;
- register long tpe = (long)(t + *t); /* trick ptr! */
-
- while (++pp <= ppe && tp <= (unsigned char *)tpe) {
- while (*pp != *tp) {
- tp = t + ++pos; /* set tp to next pos in text */
- pp = p + 1; /* set sp to start of pattern */
- }
- ++tp; /* compare next char for match (pp is incremented above) */
- }
- return(pp > ppe ? pos : 0); /* 0 if Not Found, else char position in t */
- }
-